<?php

class ConsultaSala extends CFormModel{
    public $ID_PREDIO;
    public $ID_AMBIENTE;
    public $DT_DIA;
    public $dtIni;
    public $dtFim;
    
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('ID_PREDIO, ID_AMBIENTE', 'numerical', 'integerOnly' => true),
            array(
                'ID_AMBIENTE,
                    DT_DIA,
                    ID_PREDIO,',
                'safe', 'on' => 'search'),
        );
    }
    
    public function attributeLabels() {
        return array(
            'ID_AMBIENTE' => 'Ambiente',
            'DT_DIA' => 'Dia',
            'ID_PREDIO' => 'Prédio',
        );
    }
    
    public function getSunday(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $b = date('d/m/y',$a->getTimestamp());
        return $b;
    }
    public function getMonday(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('+1 day');
        $b = date('d/m/y',$a->getTimestamp());
        return $b;
    }
    public function getTuesday(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('+2 day');
        $b = date('d/m/y',$a->getTimestamp());
        return $b;
    }
    public function getWednesday(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('+3 day');
        $b = date('d/m/y',$a->getTimestamp());
        return $b;
    }
    public function getThursday(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('+4 day');
        $b = date('d/m/y',$a->getTimestamp());
        return $b;
    }
    public function getFriday(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('+5 day');
        $b = date('d/m/y',$a->getTimestamp());
        return $b;
    }
    public function getSaturday(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('+6 day');
        $b = date('d/m/y',$a->getTimestamp());
        return $b;
    }
    public function getNextWeek(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('+7 day');
        $b = date('d/m/Y',$a->getTimestamp());
        return $b;
    }
    public function getPreviousWeek(){
        $a = DateTime::createFromFormat('Y-m-d', $this->dtIni);
        $a->modify('-7 day');
        $b = date('d/m/Y',$a->getTimestamp());
        return $b;
    }
}
?>
